package com.wjm.JavaSEAPI.APIstring;

/**
 * Data:2022年07月03日
 * Author:wjm
 * Content: String中常用API
 *
 *
 *  String replaceAll(String regex, String str)
 *         将当前字符串中符合正则表达式的内容用传进来的字符串替换掉
 *
 */
public class ReplaceAllDemo {
    public static void main(String[] args) {
        String str = "123ef456sd487df";
        //将英文之母替换为汉字
        String regex = "[a-z,A-Z]+";
        String s = "帅";
        str = str.replaceAll(regex,s);
        System.out.println(str);
        System.out.println("==================");

        //和谐用于
        String str1 = "sb你wc我我我我！";
        String regex1 = "sb|wc|nm";
        String s1 = "\\*";
        str1 = str1.replaceAll(regex1,s1);
        System.out.println(str1);
    }
}
